package com.monitor.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.monitor.dao.ErpHcMapper;
import com.monitor.dao.ErpModelMapper;
import com.monitor.dao.ErpWarehouseMapper;
import com.monitor.entity.ErpHc;
import com.monitor.entity.ErpModel;
import com.monitor.entity.ErpWarehouse;
import com.monitor.service.ErpHcService;
import com.monitor.util.Result;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

/**
 * <p>
 * 耗材明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2018-11-27
 */
@Service
public class ErpHcServiceImpl extends ServiceImpl<ErpHcMapper, ErpHc> implements ErpHcService {
	@Resource
	private ErpHcMapper erpHcMapper;
	
	@Resource
	private ErpModelMapper erpModelMapper;
	
	@Resource
	private ErpWarehouseMapper erpWarehouseMapper;
	
	@Override
	public Result<List<ErpWarehouse>> selectByCarPlate(int wareId) {
		// TODO Auto-generated method stub
		List<ErpModel> modelList=erpModelMapper.selectList(new EntityWrapper<ErpModel>().eq("pid", "SF01543141048407"));
		StringBuffer sb=new StringBuffer();
		String str="";
		if(modelList.size()>0) {
			sb.append(" AND materiel_name in ( ");
			for(ErpModel mo:modelList) {
				sb.append("'"+mo.getName()+"',");
			}
			str=sb.toString();
			str=str.substring(0, str.length()-1);
			str+=" ) ";
		}
		List<ErpWarehouse> list=erpWarehouseMapper.selectByWareIdAndName(wareId, str);
		return new Result<List<ErpWarehouse>>(list, list.size());
	}

}
